﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_password : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        btnSubmit.Click += new EventHandler(btnSubmit_Click);
        if (!IsPostBack)
        {

        }
    }

    void btnSubmit_Click(object sender, EventArgs e)
    {
        CAdmin admin = new CAdmin();
        DataRow r = admin.ReadUser(int.Parse(this.Master.UserID));
        if (null != r && r["userpwd"].ToString().ToLower() == this.tbOldPwd.Text.ToLower())
        {
            admin.ResetUserInfo(int.Parse(this.Master.UserID), r["username"].ToString(), this.tbNewPwd.Text, r["userrole"].ToString());
            ScriptManager.RegisterClientScriptBlock(Page, upEdit.GetType(), "", "alert('操作完成！');", true);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(Page, upEdit.GetType(), "", "alert('旧密码输入错误，请重新输入！');", true);
        }
    }
}